<?php /*a:2:{s:57:"D:\phpstudy_pro\yifei\muban\view\admin\cn\goods\info.html";i:1755583743;s:48:"D:\phpstudy_pro\yifei\muban\view\admin\head.html";i:1755240736;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>导航管理</title>
    <link rel="stylesheet" type="text/css" href="/static/admin/css/base.css">
<link rel="stylesheet" href="/static/admin/css/font.css">
<link rel="stylesheet" href="/static/admin/css/css.css">
<link rel="stylesheet" href="/static/admin/css/xadmin.css">
<link rel="stylesheet" href="/static/admin/css/image.css">
<script src="/static/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/admin/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/static/admin/js/xadmin.js"></script>
<script type="text/javascript" src="/static/admin/js/fl.js"></script>
<script src="/static/admin/js/falan.js"></script>
<script>var lang = "<?php echo htmlentities((string) $lang); ?>"</script>
</head>
<body>
<div class="x-body">
    <div class="layui-progress layui-progress-big" lay-showPercent="true">
        <div class="layui-progress-bar layui-bg-blue" lay-percent="80%"></div>
    </div>

    <div class="layui-form">
        <input type="text" id="id" name="id" value="<?php echo htmlentities((string) (isset($info['id']) && ($info['id'] !== '')?$info['id']:0)); ?>" style="display: none;">
        <div class="layui-form-item">
            <label class="layui-form-label">
                标题
            </label>
            <div class="layui-input-inline">
                <input type="text" id="name" name="name" required lay-verify="required"
                       autocomplete="off" class="layui-input" value="<?php echo htmlentities((string) (isset($info['name']) && ($info['name'] !== '')?$info['name']:'')); ?>"
                >
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                价格
            </label>
            <div class="layui-input-inline">
                <input type="text" id="price" name="name" required lay-verify="required"
                       autocomplete="off" class="layui-input" value="<?php echo htmlentities((string) (isset($info['price']) && ($info['price'] !== '')?$info['price']:'')); ?>"
                >
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                简单介绍
            </label>
            <div class="layui-input-inline">
                <input type="text" id="info" name="name" class="layui-input" value="<?php echo htmlentities((string) (isset($info['info']) && ($info['info'] !== '')?$info['info']:'')); ?>">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                封面图片
            </label>
            <div class="layui-input-inline">
                <input type="text" id="image_id" value="<?php echo htmlentities((string) (isset($info['image_id']) && ($info['image_id'] !== '')?$info['image_id']:0)); ?>" style="display:none;">
                <img src="<?php echo htmlentities((string) (isset($info['image']) && ($info['image'] !== '')?$info['image']:'/static/admin/img/none.jpg')); ?>" id="image" onclick="imageselect('image_id','image')" style="max-width: 150px">
                <!--<input type="file" id="image-file" style="display: none;" onchange="imagefile(this)" accept="image/*">-->
                <!--<img src="<?php echo htmlentities((string) (isset($info['image']) && ($info['image'] !== '')?$info['image']:'/static/admin/img/none.jpg')); ?>" id="image" onclick="imagesave()" style="max-width: 150px">-->
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                视频
            </label>
            <div class="layui-input-inline">
                <input type="text" id="video_id" value="<?php echo htmlentities((string) (isset($info['video_id']) && ($info['video_id'] !== '')?$info['video_id']:0)); ?>" style="display:none;">
                <input type="file" id="video-file" style="display: none;" onchange="videofile(this)" accept="video/*">
                <video src="<?php echo htmlentities((string) (isset($info['video']) && ($info['video'] !== '')?$info['video']:'/static/admin/img/none.jpg')); ?>" id="video" style="max-width: 150px">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                轮播图片
            </label>
            <div class="layui-input-inline" style="width: 750px">
                <input type="file" id="images-array-file" style="display: none;" onchange="imagesfile(this)" accept="image/*">
                <table class="table-images">
                    <thead>
                        <tr>
                            <th>图片</th>
                            <th>链接</th>
                            <th>标题</th>
                            <th>说明</th>
                            <th>排序</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody id="image-tbody">
                        <?php if(!(empty($info['images']) || (($info['images'] instanceof \think\Collection || $info['images'] instanceof \think\Paginator ) && $info['images']->isEmpty()))): if(is_array($info['images']) || $info['images'] instanceof \think\Collection || $info['images'] instanceof \think\Paginator): $i = 0; $__LIST__ = $info['images'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$value): $mod = ($i % 2 );++$i;?>
                        <tr id="image-tr-<?php echo htmlentities((string) $value['id']); ?>" name="images">
                            <td>
                                <input type="text" id="image-input-<?php echo htmlentities((string) $value['id']); ?>" name="images_id" value="<?php echo htmlentities((string) $value['id']); ?>" style="display: none">
                                <!--<img src="<?php echo htmlentities((string) $value['image']); ?>" id="image-<?php echo htmlentities((string) $value['id']); ?>" onclick="saveimages('<?php echo htmlentities((string) $value['id']); ?>')">-->
                                <img  src="<?php echo htmlentities((string) $value['image']); ?>" id="image-<?php echo htmlentities((string) $value['id']); ?>" onclick="imageselect('image-input-<?php echo htmlentities((string) $value['id']); ?>','image-<?php echo htmlentities((string) $value['id']); ?>')">
                            </td>
                            <td>
                                <input type="text" name="images_url" class="layui-input" id="image-url-<?php echo htmlentities((string) $value['id']); ?>" value="<?php echo htmlentities((string) (isset($value['url']) && ($value['url'] !== '')?$value['url']:'')); ?>">
                            </td>
                            <td>
                                <input type="text" name="images_title" class="layui-input" id="image-title-<?php echo htmlentities((string) $value['id']); ?>" value="<?php echo htmlentities((string) (isset($value['title']) && ($value['title'] !== '')?$value['title']:'')); ?>">
                            </td>
                            <td>
                                <input type="text" name="images_info" class="layui-input" id="image-info-<?php echo htmlentities((string) $value['id']); ?>" value="<?php echo htmlentities((string) (isset($value['info']) && ($value['info'] !== '')?$value['info']:'')); ?>">
                            </td>
                            <td>
                                <input type="number" name="images_sort" class="layui-input" id="image-sort-<?php echo htmlentities((string) $value['id']); ?>" value="<?php echo htmlentities((string) (isset($value['sort']) && ($value['sort'] !== '')?$value['sort']:'')); ?>">
                            </td>
                            <td>
                                <a href="javascript:;" onclick="del_image('<?php echo htmlentities((string) $value['id']); ?>')">删除</a>
                            </td>
                        </tr>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                        <?php endif; ?>
                        <tr id="image-tr-0">
                            <td>
                                <input type="text" id="image-input-0" style="display: none">
                                <img src="/static/admin/img/none.jpg" id="image-0" onclick="imageselect('image-input-0','image-0')">
                            </td>
                            <td>
                                <input type="text" class="layui-input" id="image-url-0">
                            </td>
                            <td>
                                <input type="text" id="image-title-0" class="layui-input">
                            </td>
                            <td>
                                <input type="text" id="image-info-0" class="layui-input">
                            </td>
                            <td>
                                <input type="number" id="image-sort-0" class="layui-input" value="0">
                            </td>
                            <td>
                                <a href="javascript:;" onclick="save_image(0)">添加</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                所属目录
            </label>
            <div class="layui-input-inline">
                <select id="nav_id">
                    <?php if(is_array($all) || $all instanceof \think\Collection || $all instanceof \think\Paginator): $i = 0; $__LIST__ = $all;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$value): $mod = ($i % 2 );++$i;?>
                    <option value="<?php echo htmlentities((string) $value['id']); ?>" <?php if(!(empty($info['nav_id']) || (($info['nav_id'] instanceof \think\Collection || $info['nav_id'] instanceof \think\Paginator ) && $info['nav_id']->isEmpty()))): if($info['nav_id'] == $value['id']): ?>selected<?php endif; ?><?php endif; ?>><?php echo htmlentities((string) $value['name']); ?></option>
                    <?php endforeach; endif; else: echo "" ;endif; ?>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <input type="file" id="image-attr-value" onchange="imageattrfile(this)" accept="image/*" style="display: none;">
            <label class="layui-form-label">
                规格(如颜色，尺码，型号)
            </label>
            <div class="layui-input-inline" id="attr_key" style="width: 700px">
                <div class="attr-div">
                    <!--<input type="text" class="layui-input" onchange="addak(this.value)" style="width: 170px">-->
                    <button  class="layui-input" onclick="addak('')" style="background-color:#93D1FF;color:#fff;width: 200px">添加</button>
                </div>
                <?php if(is_array($attrkey) || $attrkey instanceof \think\Collection || $attrkey instanceof \think\Paginator): $i = 0; $__LIST__ = $attrkey;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$value): $mod = ($i % 2 );++$i;?>
                <div class="attr-div" id="ak-<?php echo htmlentities((string) $value['id']); ?>">
                   <div class="attr-key">
                       <input type="text" name="attr_key" id="<?php echo htmlentities((string) $value['id']); ?>" class="layui-input" value="<?php echo htmlentities((string) $value['name']); ?>">
                       <a href="javascript:delak('<?php echo htmlentities((string) $value['id']); ?>');" class="a-k-x">X</a>
                   </div>
                   <div class="attr-list" id="av-<?php echo htmlentities((string) $value['id']); ?>">
                       <div class="attr-value">
                           <!--<input type="text" class="layui-input" onchange="addav('<?php echo htmlentities((string) $value['id']); ?>',this.value)">-->
                           <button  class="layui-input" onclick="addav('<?php echo htmlentities((string) $value['id']); ?>','')"  style="background-color:#93D1FF;color:#fff">添加</button>
                       </div>
                       <?php if(is_array($value['value_list']) || $value['value_list'] instanceof \think\Collection || $value['value_list'] instanceof \think\Paginator): $i = 0; $__LIST__ = $value['value_list'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$item): $mod = ($i % 2 );++$i;?>
                       <div class="attr-value" id="av-<?php echo htmlentities((string) $value['id']); ?>-<?php echo htmlentities((string) $item['id']); ?>">
                           <input type="text" name="<?php echo htmlentities((string) $value['id']); ?>" class="layui-input" value="<?php echo htmlentities((string) $item['name']); ?>" onchange="attrdata();">
                           <input type="text" name="images-att-<?php echo htmlentities((string) $value['id']); ?>" id="images-input-<?php echo htmlentities((string) $item['id']); ?>" value="<?php echo htmlentities((string) $item['image_id']); ?>" style="display: none">
                           <a href="javascript:imageselect('images-input-<?php echo htmlentities((string) $item['id']); ?>','image-attr-key-<?php echo htmlentities((string) $item['id']); ?>');" class="a-i" id="a-image-<?php echo htmlentities((string) $item['id']); ?>">
                               <?php if(empty($item['image']) || (($item['image'] instanceof \think\Collection || $item['image'] instanceof \think\Paginator ) && $item['image']->isEmpty())): ?>
                               <img id="image-attr-key-<?php echo htmlentities((string) $item['id']); ?>" src="/static/admin/img/none.jpg">
                               <?php else: ?>
                               <img id="image-attr-key-<?php echo htmlentities((string) $item['id']); ?>" src="<?php echo htmlentities((string) $item['image']); ?>">
                               <?php endif; ?>
                           </a>
                           <a href="javascript:delav('<?php echo htmlentities((string) $value['id']); ?>-<?php echo htmlentities((string) $item['id']); ?>');" class="a-v-x">X</a>
                       </div>
                       <?php endforeach; endif; else: echo "" ;endif; ?>
                   </div>
                </div>
                <?php endforeach; endif; else: echo "" ;endif; ?>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                SDK
            </label>
            <div class="layui-input-inline" style="width: 850px">
                <table class="table-attr">
                    <thead>
                    <tr>
                        <th>名称</th>
                        <th>图片</th>
                        <th>价格</th>
                        <th>说明</th>
                        <th>库存</th>
                        <!--<th>排序</th>-->
                    </tr>
                    </thead>
                    <tbody id="attr-tbody"></tbody>
                </table>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                内容
            </label>
            <div class="layui-input-inline">
                <script type="text/javascript" charset="utf-8" src="/ueditor-plus/dist/ueditor.config.js"></script>
                <script type="text/javascript" charset="utf-8" src="/ueditor-plus/dist/ueditor.all.js"></script>
                <script type="text/javascript" charset="utf-8" src="/ueditor-plus/lang/zh-cn/zh-cn.js?7a537435"></script>
                <script id="editor" type="text/plain" style="width:800px;height:500px;">
                    <?php if(!(empty($info['content']) || (($info['content'] instanceof \think\Collection || $info['content'] instanceof \think\Paginator ) && $info['content']->isEmpty()))): ?><?php echo $info['content']['content']; ?><?php endif; ?>
                </script>
                <script type="text/javascript">
                // 初始化编辑器
                var ue = UE.getEditor('editor');
                </script>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="add" lay-submit="">
                确认
            </button>
        </div>
    </div>
</div>
<script>
    var attr_list = '<?php if(!(empty($attr) || (($attr instanceof \think\Collection || $attr instanceof \think\Paginator ) && $attr->isEmpty()))): ?><?php echo $attr; ?><?php endif; ?>';
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form,layer = layui.layer;
        //监听提交
        form.on('submit(add)', function(){
            attrdata();
            console.log(attr_data);
            let message = {
                name:document.getElementById('name').value,
                price:document.getElementById('price').value,
                images:getimagesid(),
                attr:getattr(),
                attrkey:attr_data,
                info:document.getElementById('info').value,
                image_id:document.getElementById('image_id').value,
                nav_id:document.getElementById('nav_id').value,
                content:ue.getContent()
            };
            //发异步，把数据提交给php
            post('/sys/goods/save?id=<?php echo htmlentities((string) (isset($info['id']) && ($info['id'] !== '')?$info['id']:0)); ?>',message);
        });
    });
    function post_result(res){
        layer.alert("操作成功", {icon: 6},function () {
            // 获得frame索引
            var index = parent.layer.getFrameIndex(window.name);
            //关闭当前frame
            parent.layer.close(index);
            parent.location.reload();
        });
    }
    attrdata();
</script>
</body>
</html>